import Mock from "mockjs"


const {data} = Mock.mock({
            'data|100':[
                {
                    'img': "@image('80x120', '@color()' )",


                    'title':'@cparagraph(3, 5)'

                }
            ]
})
Mock.mock('/api/getGoodsList','post',(config:any)=>{
    const req = JSON.parse(config.body);
    return {
        goodList:data.slice((req.page - 1) * 10,req.page * 10),
        count:data.length,
        msg:'数据获取成功',
        code:200
      
    }
})


// 办理借书模块，点击第一个扫描
const phone = Mock.mock(/^1[3456789]\d{9}$/);
const {bookuserdata} = Mock.mock({
    
    'bookuserdata|1':[
        {
            'name': "@cname()",
            'phone':phone,
        }
    ]
})
Mock.mock('/api/getScanBook','get',()=>{

return {

data:bookuserdata,
msg:'数据获取成功',
code:200

}
})

// 点击第二个扫描

const {bookdata} = Mock.mock({
    
    'bookdata|1':[
        {
            'id':1,
            'img': "@image('80x120', '@color()' )",
            'name': "@cname()",
            'title':'@cparagraph(2, 3)'
        }
    ]
})
Mock.mock('/api/getBook','get',()=>{

return {

data:bookdata,
msg:'数据获取成功',
code:200

}
})

Mock.mock('/api/deleteBook', 'post', (options:any) => {
    const id = JSON.parse(options.body).id;
  
    let bookdata = data.filter((item:any) => item.id !== id);
    
    return {
      data:bookdata,
      code: 200,
      message: '删除成功'
    }
  })

// 获取盘点书籍列表
const {statistics} = Mock.mock({
    
    'statistics|1':[
        {
            'id':1,
            'img': "@image('80x120', '@color()' )",
            'name': "@cname()",
            'discharged':11,
            'inlibrary':12,
            'lendout':13,
            'purchase':14
        }
    ]
})
Mock.mock('/api/getstatisticsBook','get',()=>{
return {

data:statistics,
msg:'数据获取成功',
code:200

}
})